package thread;

// 线程是否被结束
public class test7 {
    private static boolean flg = true;

    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (flg) {
                System.out.println("thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        flg = false;
    }
}
